package com.qboot.filestorage.aspect;

import cn.hutool.core.date.DateUtil;
import cn.xuyanwu.spring.file.storage.FileInfo;
import cn.xuyanwu.spring.file.storage.UploadPretreatment;
import cn.xuyanwu.spring.file.storage.aspect.FileStorageAspect;
import cn.xuyanwu.spring.file.storage.aspect.UploadAspectChain;
import cn.xuyanwu.spring.file.storage.platform.FileStorage;
import cn.xuyanwu.spring.file.storage.recorder.FileRecorder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 对象存储切面
 *
 * @author Tellsea
 * @date 2023/2/17
 */
@Slf4j
@Component
public class DefaultFileStorageAspect implements FileStorageAspect {

    @Override
    public FileInfo uploadAround(UploadAspectChain chain, FileInfo fileInfo, UploadPretreatment pre, FileStorage fileStorage, FileRecorder fileRecorder) {
        fileInfo.setPath(DateUtil.format(DateUtil.date(), "yyyy/MM/dd/"));
        fileInfo = chain.next(fileInfo, pre, fileStorage, fileRecorder);
        return fileInfo;
    }
}
